<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of CropStatusAction
 *
 * @author Levz
 */
class CropStatusAction extends CAction {

    public function run() {
        if (Yii::app()->request->isPostRequest) {
            $model = Crop::model()->findByPk($_GET['cid']);
            $model->is_active = ($model->is_active == 1) ? 0 : 1;
            
            
            if($model->save()) {
                echo 'crop status has been changed.';
            } else {
                echo 'error changing status.';
            } 
        }
        else
            throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
    }

}

?>
